<!DOCTYPE html>
<html>
<head>
    <meta name="layout" content="main"/>
    <g:set var="entityName" value="${message(code: 'estate.label', default: 'estate')}"/>
    <title>押品</title>
    <style>
    .table>tbody>tr>td{
        vertical-align: middle;
    }
    @media screen and (min-width:1900px) and (max-width:1920px) {
        .flex{
            display: flex;justify-content: center;align-items: center;
        }
    }
    .select2-container .select2-choices .select2-search-field input,.select2-container .select2-choice,.select2-container .select2-choices{

        color: #999;
    }
    </style>
</head>

<body class="fixed-navbar fixed-sidebar">
<div class="small-header">
    <div class="hpanel">
        <div class="panel-body">
            <div id="hbreadcrumb" class="pull-right">
                <ol class="hbreadcrumb breadcrumb">
                    <li>CINDATA PLS</li>
                    <li class="active">
                        <span>押品</span>
                    </li>
                </ol>
            </div>

            <h2 class="font-light m-b-xs">
                押品
            </h2>
        </div>
    </div>
</div>
<div class="content animate-panel">
    <div class="row">
        <g:form method="POST" action="searchEstate" class="form-horizontal" role="form" id="form">
            <div class="hpanel hblue">
                <div class="panel-heading">
                    <div class="panel-tools">
                        <button class="btn btn-primary btn-xs" type="submit" onclick="text()"><i class="fa fa-search"></i> 查询</button>
                        <button class="btn btn-warning2 btn-xs" type="button" id="resetBtn">
                            <i class="fa fa-times"></i> 重置</button>
                    </div>
                    查询
                </div>
                <div class="panel-body seach-group" id="bug1">
        %{--第一行--}%
            <div class="row flex">
                <div class="form-group col-sm-4">
                    <label for="district" class="col-sm-3 control-label">城市</label>
                    <div class="col-sm-9">
                        <g:select class="form-control" name="city" id="city"
                                  from="${com.cindata.City.executeQuery("select distinct e.city as city from Estate e where e.city.id <> 2")}"
                                  valueMessagePrefix="status" optionKey="zoneNumber" optionValue="name"
                                  value="${params?.city}"
                                  noSelection="${["-1": '请选择城市']}"/>
                        <input type="hidden" id="communityId" value="${params?.communityId}" name="communityId" />
                    </div>
                </div>
                <div class="form-group col-sm-4">
                    <label class="col-sm-3 control-label" for="loansDuration">贷款时长</label>
                    <div class="col-sm-9">
                        <g:select class="form-control" name="loansDuration" id="loansDuration"
                                  from="${com.cindata.dimension.YearLimitDimension.list()}"
                                  valueMessagePrefix="status" optionKey="label" optionValue="label"
                                  value="${params?.loansDuration}"
                                  noSelection="${["": '请选择贷款时长']}"/>
                    </div>
                </div>
                <div class="form-group col-sm-4">
                    <label for="district" class="col-sm-3 control-label">贷款金额</label>
                    <div class="col-sm-7 input-group ">
                        <input type="text" class=" form-control " placeholder="请输入下限" maxlength="6"
                               id="loansAmountStart" value="${params?.loansAmountStart}" name="loansAmountStart" />
                        <span class="input-group-addon">至</span>
                        <input type="text" class=" form-control " placeholder="请输入上限" maxlength="6"
                               id="loansAmountEnd" value="${params?.loansAmountEnd}" name="loansAmountEnd" />
                    </div>
                    <div class="col-sm-2 p-t-xss">
                        万元
                    </div>
                </div>
            </div>
        %{--第二行--}%
            <div class="row flex">
                <div class="form-group col-sm-4">
                    <label for="district" class="col-sm-3 control-label">行政区</label>
                    <div class="col-sm-9">
                        <g:select class="form-control" name="district" id="district"
                                  from="${districtList}"
                                  valueMessagePrefix="status" optionKey="zoneNumber" optionValue="name"
                                  value="${params?.district}"
                                  noSelection="${["null": '请选择行政区']}"/>
                    </div>
                </div>
                <div class="form-group col-sm-4">
                    <label for="district" class="col-sm-3 control-label">押品状态</label>
                    <div class="col-sm-9">
                        <g:select class="form-control" name="isEstate" id="isEstate"
                                  from="${[[name:'已押',value:'true'],[name:'未押',value:'false']]}"
                                  valueMessagePrefix="status" optionKey="value" optionValue="name"
                                  value="${params?.isEstate}"
                                  noSelection="${["": '请选择押品状态']}"/>
                    </div>
                </div>
                <div class="form-group col-sm-4">
                    <label for="district" class="col-sm-3 control-label">贷款余额</label>
                    <div class="col-sm-7  input-group">
                        <input type="text" class=" form-control "
                               placeholder="请输入下限" id="loansBalanceStart" maxlength="6"
                               value="${params?.loansBalanceStart}" name="loansBalanceStart" />
                        <span class="input-group-addon">至</span>
                        <input type="text" class="form-control " placeholder="请输入上限" maxlength="6"
                               id="loansBalanceEnd"  value="${params?.loansBalanceEnd}" name="loansBalanceEnd" />
                    </div>
                    <div class="col-sm-2 p-t-xss">
                        万元
                    </div>
                </div>
            </div>
        %{--第三行--}%
            <div class="row flex">
                <div class="form-group col-sm-4">
                    <label for="district" class="col-sm-3 control-label">房屋坐落</label>
                    <div class="col-sm-9">
                        <input type="text" class="form-control" name="sourceAddress" id="sourceAddress" value="${params?.sourceAddress}" placeholder="请输入房屋坐落">
                    </div>
                </div>
                <div class="form-group col-sm-4">
                    <label class="col-sm-3 control-label" >押品风险</label>
                    <div class="col-sm-9">
                        <g:select class="form-control" name="risk" id="risk"
                                  from="${com.cindata.dimension.RiskDimension.list()}"
                                  valueMessagePrefix="status" optionKey="label" optionValue="label"
                                  value="${params?.risk}"
                                  noSelection="${["": '请选择押品风险']}"/>
                    </div>
                </div>
                <div class="form-group col-sm-4">
                    <label  class="col-sm-3 control-label">面积范围</label>
                    <div class="col-sm-7  input-group">
                        <input type="text" class=" form-control " placeholder="请输入下限" id="buildAreaStart" maxlength="6"
                               value="${params?.buildAreaStart}" name="buildAreaStart" />
                        <span class="input-group-addon">至</span>
                        <input type="text" class="form-control " placeholder="请输入上限" id="buildAreaEnd" maxlength="6"
                               value="${params?.buildAreaEnd}" name="buildAreaEnd" />
                    </div>
                    <div class="col-sm-2 p-t-xss">
                        平米
                    </div>
                </div>
            </div>
        %{--第四行--}%
            <div class="row flex">
                %{--受理网点名称--}%
                <div class="form-group col-sm-4">
                    <label for="district" class="col-sm-3 control-label">房屋用途</label>
                    <div class="col-sm-9">
                        <g:select class="form-control" name="residentialType" id="residentialType"
                                  from="${com.cindata.dictionary.BuildingTypeDict.listOrderById()}"
                                  valueMessagePrefix="status" optionKey="code" optionValue="name"
                                  value="${params?.residentialType}"
                                  noSelection="${["": '请选择房屋用途']}"/>
                    </div>
                </div>
                <div class="form-group col-sm-4">
                    <label for="district" class="col-sm-3 control-label">放款时间</label>
                    <div class="col-sm-9 input-daterange input-group p-r-n"  id="datepicker" style="width: 75%;">
                        <input type="text" class=" form-control " placeholder="请选择放款时间"
                               value="${params?.startDateStart}" name="startDateStart" id="startDateStart" style="text-align: left" />
                        <span class="input-group-addon">至</span>
                        <input type="text" class=" form-control " placeholder="请选择结束时间"
                               value="${params?.startDateEnd}" name="startDateEnd" id="startDateEnd" style="text-align: left" />
                    </div>
                </div>
                <div class="form-group col-sm-4">
                    <label for="district" class="col-sm-3 control-label">受理网点</label>
                    <div class="col-sm-7">
                        <g:select class="form-control" name="accountId" id="accountId"
                                  from="${accountManageAccountList}"
                                  valueMessagePrefix="status" optionKey="id" optionValue="name"
                                  value="${params?.accountId}"
                                  noSelection="${["": '请选择受理网点名称']}"/>
                    </div>
                </div>
            </div>
            </div>
        </g:form>
    </div>
    </div>
    <div class="row">
        <div class="hpanel hgreen">
            <div class="panel-heading">
                <div class="panel-tools">
                    %{--<g:link action="create" class="btn btn-info btn-xs" data-toggle="modal"--}%
                    %{--data-target="#myModal7"><i class="glyphicon glyphicon-download-alt"></i></g:link>--}%
                    %{--<span onclick=" searchMap()" style="cursor: pointer; color: #3498DB;"><i class="fa fa-map-marker" style="color: red; padding-right: 5px; font-size: 18px;"></i>查看地图分布</span>--}%
                    <button class="btn btn-warning2 btn-xs" type="submit" onclick="searchMap()"><i class="fa fa-map-marker"></i> 查看地图</button>
                    <a class="showhide"><i class="fa fa-chevron-up"></i></a>
                </div>
                &nbsp;&nbsp;
            </div>
            <g:if test="${params?.residentialType == 'Residential'}">
                <g:include view="estate/listResidential.gsp" params="${[:] << params}"></g:include>
            </g:if>
            <g:elseif test="${params?.residentialType == 'Business'}">
                <g:include view="estate/listBusiness.gsp" params="${[:] << params}"></g:include>
            </g:elseif>
            <g:elseif test="${params?.residentialType == 'Office'}">
                <g:include view="estate/listOffice.gsp" params="${[:] << params}"></g:include>
            </g:elseif>
            <g:elseif test="${params?.residentialType == 'Industry'}">
                <g:include view="estate/listIndustry.gsp" params="${[:] << params}"></g:include>
            </g:elseif>
            <g:else>
                <g:include view="estate/listCommon.gsp" params="${[:] << params}"></g:include>
            </g:else>
            <div class="panel-footer">
                <div class="pagination">
                    <g:paginate action="searchEstate" total="${estateCount ?: 0}" params="${params}"/>
                </div>
            </div>
        </div>
    </div>
</div>
<g:javascript>
        function searchMap() {
        var risk=$("#risk").val(),
            city=$('#city').val(),
            district=$('#district').val(),
            precinct=$('#precinct').val(),
            inputData={
                risk:risk,
                city:city,
                district:district,
                precinct:precinct
            };
        if(city=="-1"){
            toastr.error('请选择城市');
            return
        }
        //window.location.href="/map/cluster?currentMap=clusterMap&flag=true&city="+$("#city").val()+"&district="+$("#district").val()+"&communityId="+$("#communityId").val();
        window.location.href="/newMap/cluster?currentMap=clusterMap&city="+$("#city").val()+"&district="+$("#district").val()+"&communityId="+$("#communityId").val();
        }
    $(function () {

        $("#resetBtn").click(function () {
            $("#fullName").val("");
        })

        $('#datepicker').datepicker({
            language: 'zh-CN'
        });
        $("#datepicker").on("changeDate", function(event) {
            $("#my_hidden_input").val(
                    $("#datepicker").datepicker('getFormattedDate')
            )
        });

        // $('#esateTable').footable();

        $('.input-group.date').datepicker({ });
        $('.input-daterange').datepicker({ });
        var flag;
        $("#city").bind("change", function(){
            if('${params.district}'== $("#district option:selected").val()&&flag!=true){
                flag=true
                return
            }
            $("#district option").remove();
            $("#s2id_district span:first").html("请选择行政区");
            var city = $("#city").val()
            $("#district").append("<option value='-1' >请选择行政区</option>")
            if(city=='-1'){
                return
            }
            $.ajax({
                url: "/estate/districtList",
                type: "POST",
                data: {'city': city} ,
                success: function(result){
                    for(var i=0; i < result.districtList.length; i++){
                        $("#district").append("<option value=" + result.districtList[i].zoneNumber + ">" + result.districtList[i].name + "</option>")
                    }
                }
            });
        });
        $("#city").change();

    });
    //重置按钮
    $("#resetBtn").click(function () {
        $("#s2id_risk span:first").html("请选择押品风险");
        $("#s2id_loansDuration2 span:first").html("请选择受理网点名称");
        $("#risk").val('');
        $("#s2id_city span:first").html("请选择城市");
        $("#city").val("");
        $("#s2id_district span:first").html("请选择行政区");
        $("#district").val("");
        $("#loansAmountStart").val("");
        $("#loansAmountEnd").val("");
        $("#account").val("");
        $("#loansBalanceStart").val("");
        $("#loansBalanceEnd").val("");
        $("#sourceAddress").val("");
        $("#startDateEnd").val("");
        $("#startDateStart").val("");
        $("#s2id_loansDuration span:first").html("请选择贷款时长");
        $("#loansDuration").val("");
        $("#s2id_remainTime span:first").html("请选择剩余还款时长");
        $("#remainTime").val("");
        $("#buildAreaStart").val("");
        $("#buildAreaEnd").val("");
        $('#s2id_residentialType span:first').html('请选择房屋用途');
        $('#s2id_isEstate span:first').html('请选择押品状态');
        $('#s2id_accountId span:first').html('请选择受理网点名称');
        $('#residentialType').val('');
        $('#isEstate').val('');
        $("#accountId").val('');
        $("#communityId").val('');
    });
//      限制
    $(function(){
        function text(){
            if(loansAmountStart.value<0||loansAmountStart.value>214748||loansAmountEnd.value<0||loansAmountEnd.value>214748||loansAmountEnd.value<0||loansAmountEnd.value>214748
                ||loansBalanceStart.value<0||loansBalanceStart.value>214748||buildAreaStart.value<0||buildAreaStart.value>214748||buildAreaEnd.value<0||buildAreaEnd.value>214748){
                alert("值应0-214748之间");
                loansAmountStart.value ='';
                loansAmountEnd.value='';
                loansBalanceStart.value='';
                loansBalanceEnd.value='';
                buildAreaStart.value='';
                buildAreaEnd.value='';
            }
        }

    })

</g:javascript>

</body>
</html>
